<#assign base=request.contextPath>
<!DOCTYPE html> 
<html>
	<head>
		<title>${title}</title>
		<meta charset="utf-8">
		<#include "common/reference.ftl" />
		<#include "common/am.reference.ftl" />
	</head>
	<body class="${configs["skinName"]}">
		<div class="page-content">
			<div class="row">
			<#if viewMode !="view">
			<#include "common/breadcrumb.ftl">
			</#if>
				<form id="form" role="form" class="form-horizontal" method="post" action="${base}/${form_action}">
					<div class="col-xs-12">
						<div class="widget-box">
							<div class="widget-body">
								<input type="hidden" name="appId" id="appId" value="${model.appId}" <#if viewMode == "view">disabled</#if>>
								<#if viewMode == "view">
								<div class="widget-header widget-header-flat">
									<h5 class="lighter">
										${module}
									</h5>
								</div>
								<#else>
								<div class="alert alert-warning">
									<strong>提示!</strong>
									<strong style="color:#dd514c;">出现红框</strong>的表示不能为空
									<strong>IOS尺寸(宽高):640 x 960，640 x 1136，750 x 1334，1080 x 1920；安卓尺寸(宽高):480 x 800，800 x 1280，1080 x 1920</strong>
								</div>
								</#if>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										适用平台
									</label>
									<div class="col-sm-6">
										<select name="platform" class="select-chosen form-control" required <#if viewMode == "view">disabled</#if> placeholder="请选择平台">
										<#list platforms as platform >
											<#if platform.platformName?lower_case?contains('ios') || 
												 platform.platformName?lower_case?contains('android') ||
												 platform.platformName?lower_case?contains('苹果') ||
												 platform.platformName?lower_case?contains('安卓')>
											<option value="${platform.platformValue}" <#if (!model.platform?contains(',') && model.platform == platform.platformValue) || model.platform?contains('${platform.platformValue},')  || model.platform?contains(',${platform.platformValue}') >selected="selected"</#if> >${platform.platformName}</option>
											</#if>
										</#list>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										图片宽度
									</label>
									<div class="col-sm-6">
										<div class="input-group">
											<input type="text" class="input-mini form-control js-pattern-number" id="width" name="width" value="${model.width}" required min="1"/>
											<span class="input-group-addon">像素(px)</span>
										</div>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										图片高度
									</label>
									<div class="col-sm-6">
										<div class="input-group">
											<input type="text" class="input-mini form-control js-pattern-number" id="height" name="height" value="${model.height}" required min="1"/>
											<span class="input-group-addon">像素(px)</span>
										</div>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										启动页图片
									</label>
									<div class="col-sm-6">
										<#if viewMode !="view">
										<input type="file" id="imageFile" name="file" value="" class="form-control" data-input="imageInput" data-image="imagePreview">
										</#if>
										<input type="hidden" id="imageInput" name="picture" value="${model.picture}"/>
										<img id="imagePreview" alt="" src="<#if model.picture?exists && model.picture?length gt 0>${model.picture}</#if>" height="60" style="display:<#if model.picture?exists && model.picture?length gt 0>block<#else>none</#if>" />
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label no-padding-right">
										是否启用
									</label>
									<div class="col-sm-6">
										<input class="ace ace-switch ace-switch-7" type="checkbox" name="enabled" <#if model == null || model.enabled>checked="checked"</#if> <#if viewMode == "view">disabled</#if>>
										<span class="lbl"></span>
									</div>
								</div>
								<#if viewMode != "view">
								<div class="clearfix form-actions">
									<div class="col-md-offset-3 col-md-9">
										<button id="btnSubmit" class="btn btn-info" type="submit">
											<i class="fa fa-check bigger-110"></i>
											提 交
										</button>
									</div>
								</div>
								</#if>
							</div>
						</div>
					</div>
				</form>
			</div>	
		</div>
		<script type="text/javascript">
		$(function(){
			$('.select-chosen').chosen();
			
			$('#startMonth').ace_spinner({min:10,max:12,step:1,btn_up_class:'btn-info fa fa-caret-up' , btn_down_class:'btn-info fa fa-caret-down'});
			$('#startDay').ace_spinner({min:1,max:31,step:1,btn_up_class:'btn-info fa fa-caret-up' , btn_down_class:'btn-info fa fa-caret-down'});
			$('#endMonth').ace_spinner({min:1,max:12,step:1, btn_up_class:'btn-info fa fa-caret-up' , btn_down_class:'btn-info fa fa-caret-down'});
			$('#endDay').ace_spinner({min:1,max:31,step:1, btn_up_class:'btn-info fa fa-caret-up' , btn_down_class:'btn-info fa fa-caret-down'});
			var startMonth =<#if model?exists && model.startMonth gt 0>${model.startMonth}<#else>1</#if>;
			if(startMonth < 1) startMonth = 1;
			if(startMonth > 12) startMonth = 12;
			var startDay = <#if model?exists && model.startDay gt 0>${model.startDay}<#else>1</#if>;
			if(startDay < 1 ) startDay = 1;
			var endMonth = <#if model?exists && model.endMonth gt 0>${model.endMonth}<#else>1</#if>;
			if(endMonth < 1) endMonth = 1;
			if(endMonth > 12) endMonth = 12;
			var endDay = <#if model?exists && model.endDay gt 0>${model.endDay}<#else>1</#if>;
			if(endDay < 1) endDay = 1;
			
			$('#startMonth').val(startMonth);
			$('#startDay').val(startDay);
			$('#endMonth').val(endMonth);
			$('#endDay').val(endDay);
			
			$('input[type="file"]').ace_file_input(imageParms).on('change',function(){
				var fileId = $(this).attr('id');
				var inputid = $(this).attr('data-input');
				var previewId = $(this).attr('data-image');
				openLoading();
				$.ajaxFileUpload({
		                url: '${base}/upload/image', 
		                type:'POST',
		                data:{module:'app',hasRoot:true},          
		                secureuri: false,
		                fileElementId: fileId,                   //文件选择框的id属性
		                dataType: 'json',                       
		                success: function (rst){
		                    if(rst.status == 'OK' && rst.link != ''){
			                    $('#'+previewId).attr('src',rst.link).show();
		                    	$('#'+inputid).val(rst.link);
		                    }
		                    else{
		                    	layer.alert(rst.message);
		                    }
		                },
		                error: function (data, status, e) {
		                    layer.alert('上传图片失败');
		                },
		                complete:function(){
		                	closeLoading();
		                }
		          });
			});
			$('#form').validator();
		})
		</script>
	</body>
</html>